package main.java.game.event;


import java.util.Random;

import main.java.game.Game;
import main.java.game.item.Treasure;
import main.java.game.item.equipableTreasure.EquipableTreasure;

public class TreasureFind extends Event {
	public TreasureFind(String name, Boolean subscribed){
		super(name,subscribed);
		
	}
	public void takeEffect(Game game){
		super.takeEffect(game);
		
		Random random = new Random();
		Integer index = Math.abs(random.nextInt()%game.getTreasures().get(1).size());
		Treasure treasure=game.getTreasures().get(1).get(index);
		game.getPlayer().getTreasures().add(treasure);
		game.getTreasures().get(treasure.getLevel()).remove(treasure);
		if(treasure instanceof EquipableTreasure)
			game.getPlayer().getEquipablesTreasures().add(treasure);
		System.out.println("You win the treasure: "+treasure.getName()+"!\n");
	}
}
